package com.yidu.controller;

import com.yidu.entity.Menu;
import com.yidu.service.MenuService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class MenuController {
    @Resource
    MenuService menuService;
    @RequestMapping("/MenuTable")
    public String MenuTable(){
        return "MenuTable";
    }
    @RequestMapping("/selectMenu")
    @ResponseBody
    public Map selectMenu(int page, int limit){
        List<Menu> menuList = menuService.selectMenu(page, limit);
        Map map = new HashMap();
        map.put("code",0);
        map.put("msg",":");
        map.put("count",100);
        map.put("data",menuList);
        return map;
    }
    @RequestMapping("/insertMenu")
    public void insertMenu(Menu menu){
        menuService.insertMenu(menu);
    }
    @RequestMapping("/updateMenu")
    public void updateMenu(Menu menu){
        menuService.updateMenu(menu);
    }
    @RequestMapping("/deleteMenu")
    public void deleteMenu(int menuId){
        menuService.deleteMenu(menuId);
    }
}
